<template>
    <a-form-model ref="form" :model="mdl" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-row :span="24">
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.appName','应用名称')" prop="name">
                    <a-input :placeholder="i18n('form.appName','应用名称','input')" v-model="mdl.name"/>
                </a-form-model-item>
            </a-col>
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.enterpriseID','企业ID')" prop="corpId">
                    <a-input :placeholder="i18n('form.enterpriseID','企业ID','input')" v-model="mdl.corpId"/>
                </a-form-model-item>
            </a-col>
        </a-row>
        <a-row :span="24">
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.appID','应用ID')" prop="agentId">
                    <a-input :placeholder="i18n('form.appID','应用ID','input')" v-model="mdl.agentId"/>
                </a-form-model-item>
            </a-col>
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.appKey','应用KEY')" prop="appKey">
                    <a-input :placeholder="i18n('form.appKey','应用KEY','input')" v-model="mdl.appKey"/>
                </a-form-model-item>
            </a-col>
        </a-row>
        <a-row :span="24">
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.secretKey','密钥')" prop="secret">
                    <a-input :placeholder="i18n('form.secretKey','密钥','input')" v-model="mdl.secret"/>
                </a-form-model-item>
            </a-col>
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.appType','应用类型')" prop="type">
                    <a-radio-group v-model="mdl.type" :default-value="1">
                        <a-radio value="1">
                            {{i18n('appTypeMap.H5app','H5应用')}}
                        </a-radio>
                        <a-radio value="2">
                            {{i18n('appTypeMap.applet','小程序')}}
                        </a-radio>
                    </a-radio-group>
                </a-form-model-item>
            </a-col>
        </a-row>
        <a-row :span="24">
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.H5Homepage','H5主页')">
                    <a-input :placeholder="i18n('form.H5Homepage','H5主页','input')" v-model="mdl.h5HomePage"/>
                </a-form-model-item>
            </a-col>
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.pcHomepage','PC主页')">
                    <a-input :placeholder="i18n('form.pcHomepage','PC主页','input')" v-model="mdl.pcHomePage"/>
                </a-form-model-item>
            </a-col>
        </a-row>
        <a-row :span="24">
            <a-col :span="12">
                <a-form-model-item :label="i18n('form.backgroundHomepage','后台主页')">
                    <a-input :placeholder="i18n('form.backgroundHomepage','后台主页','input')" v-model="mdl.adminHomePage"/>
                </a-form-model-item>
            </a-col>
        </a-row>
    </a-form-model>
</template>

<script>
    import {BaseFormModel, RxDialog} from "@lowcode/jpaas-common-lib";

    export default {
        name: "Platformsdingding",
        mixins: [BaseFormModel],
        components: {
            RxDialog
        },
        props: ["dataJson"],
        data() {
            return {
                rules: {
                    name: [
                        {required: true, message: this.i18n('form.appName','应用名称','input'), trigger: 'blur'},
                    ],
                    agentId: [
                        {required: true, message: this.i18n('form.appID','应用ID','input'), trigger: 'blur'},
                    ],
                    corpId: [
                        {required: true, message: this.i18n('form.enterpriseID','请输入企业ID','input'), trigger: 'blur'},
                    ],
                    appKey: [
                        {required: true, message: this.i18n('form.appKey','请输入应用key','input'), trigger: 'blur'},
                    ],
                    secret: [
                        {required: true, message: this.i18n('form.secretKey','密钥','input'), trigger: 'blur'},
                    ],
                    type: [
                        {required: true, message: this.i18n('form.typeName','请选择类型','select'), trigger: 'blur'},
                    ]
                }
            }
        },
        created() {
            if (!this.dataJson || !this.dataJson.corpId) {
                return;
            }
            this.mdl = this.dataJson;
        },
        methods: {
            i18n(name, text, key) {
                return this.$ti18(name, text, "platForms", key);
            },
            checkAndSave(callback) {
                this.$refs.form.validate(valid => {
                    if (!valid) {
                        return;
                    }
                    callback(this.mdl);
                });
            },
        }
    }
</script>

<style scoped>

</style>